package com.ssims.service.client;

import main.java.ssims.front.dao.fim.ISupplierDAO;
import main.java.ssims.front.entity.SupplierEntity;
import main.java.ssims.front.service.BaseService;
import main.java.ssims.front.service.fim.ISupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by coliza on 2014/5/11.
 */
@Transactional
@Service("supplierService")
public class SupplierService extends BaseService implements ISupplierService {
    @Autowired
    private ISupplierDAO supplierDAO;

    @Override
    public List<SupplierEntity> queryByParams() {
        return supplierDAO.query();
    }

    @Override
    public List<SupplierEntity> saveAndRefresh(SupplierEntity entity) {
        supplierDAO.insert(entity);
        return supplierDAO.query();
    }

    @Override
    public SupplierEntity updateCusInfo(SupplierEntity entity) {
        boolean success = supplierDAO.update(entity);
        if (success) {
            return supplierDAO.queryById(entity.getId());
        }
        return null;
    }

    @Override
    public boolean delete(Integer id) {
        return supplierDAO.delete(id);
    }
}
